/* *********
 *    Author: Jason He;
 *    Version: 0.0.1;
 *    Date: 2016-12-19;
 *    File: list.js;
 ********* */

$(document).ready(function () {
	// phone validate
	$("#nodata-phone-input").change(function () {
		$("#nodata-phone-error").text("");
	});
	$("#nodata-phone-btn").click(function () {
		var phone = $("#nodata-phone-input").val();
		if (phone) {
			var reg = new RegExp(/^(1[34578]\d{9})|^(0\d{2,3}-?\d{7,8})$/);
			if (reg.test(phone)) {
				$.ajax({
				  type: 'POST',
				  url: "/Home/Seller/addPhone",
				  data: {phone:$('#nodata-phone-input').val(),phoneneed:$('#condition').val()},
				  dataType:'json',
				  success:function(res){
					  if(res.id==1)
					  {
						  alert(res.msg);
					  }else
					  {
						  alert('出现异常，请联系客服');
					  }
				  }
				});
				//alert("提交成功。请继续浏览其他车源，等待我们的好消息哦~");
			} else {
				$("#nodata-phone-error").text("*请填写正确的手机号码").show();
				$("#nodata-phone-input").focus();
				return false;
			}
		} else {
			$("#nodata-phone-error").text("*忘记填写手机号啦").show();
			$("#nodata-phone-input").focus();
			return false;
		}
	});
});